<!--
  @author yangjiangming
  @date 2018-12-10 20:40:28
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html th:replace="~{work/modify/common/layout :: layout('核配件', ~{::title}, ~{::content}, ~{::script})}">
<head>
    <title>工单管理-核配件</title>
</head>
<body>

<div class="content" th:fragment="content">
    <style>
        .d-wrapper {
            width: 100%;
            display: flex;
            justify-content: space-between;
        }

        .d-wrapper .left {
            width: 45%;
            padding: 5px 10px;
            border: 1px solid #eee;
            box-sizing: border-box;
        }

        .d-wrapper .right {
            width: 53%;
            padding: 5px 10px;
            border: 1px solid #eee;
            box-sizing: border-box;
        }

        .is-use-parts {
            display: none;
        }

        .sum-item {
            display: none;
        }

        .sum-item-1, .sum-item-2, .sum-item-3 {
            color: red;
        }

        .right tbody .layui-table-cell{
            height: 140px;
            line-height: 140px;
        }

        .right tbody .layui-table-cell .layui-upload-drag{
            line-height: 28px;
        }

        .right tbody .layui-table-cell .btn-img {
            line-height: 28px;
        }

        .is-use-parts tbody .layui-table-cell{
            height: 140px;
            line-height: 140px;
        }

        .is-use-parts tbody .layui-table-cell .layui-upload-drag{
            line-height: 28px;
        }

        .is-use-parts tbody .layui-table-cell .btn-img {
            line-height: 28px;
        }

    </style>
    <form action="" class="layui-form">
        <input type="text" th:value="${partVO.orderId}" name="orderId" hidden>
        <input type="text" th:value="${partVO.workId}" name="workId" hidden>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 60px;">使用配件</label>
            <div class="layui-inline is-use-parts-item">
                <input type="radio" class="useparts" value="2" title="使用配件" name="used">
                <input type="radio" class="nouseparts" value="1" title="未用配件" checked name="used">
            </div>
        </div>
        <div class="layui-form-item is-use-parts" th:if="${#lists.size(partVO.partMasterVOList) > 0 }">
            <label class="layui-form-label" style="width: 60px;">内采网购</label>
            <div class="layui-inline" style="width: 800px">
                <div class="layui-form-item" th:each="items : ${partVO.partMasterVOList}">
                    <span  class="layui-btn d-edit" th:id="${items.masterId}" th:data-mastername="${items.masterName}" lay-filter="inner-purchase" style="margin-right: 10px;">
                        <i class="layui-icon layui-icon-add-1"></i>
                        编辑
                    </span>
                    <div class="layui-inline" style="padding: 7px 0px;">
                        <span th:text="${items.masterTypeName}"></span> : <span th:text="${items.masterName}">李磊</span>
                    </div>
                    <div class="layui-inline " style="margin-left: 100px;">
                        <div class="sum-item">
                            总额:￥<span class="sum-item-1"></span>
                        </div>
                    </div>
                    <div class="table-render">
                        <table class="layui-table" th:id="|inner-purchase-table${items.masterId}|"
                               th:lay-filter="|inner-purchase-table${items.masterId}|"></table>
                    </div>
                </div>

            </div>
        </div>

        <div class="layui-form-item no-use-parts">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="confirm" style="margin-left: 90px;">
                保存
            </button>
            <span>未消耗配件可不填写配件和配件总价</span>
        </div>

    </form>
    <div id="view"></div>
</div>

<!--弹框-->
<script type="text/html" id="tpl-list">
    <input type="text" value="" class="index" hidden>
    <form action="" class="layui-form">
        <div class="layui-form-item d-wrapper">
            <div class="left">
                <p>双击添加配件</p>
                <hr class="layui-bg-gray">
                <p style="padding-left: 15px;">工具箱</p>
                <hr class="layui-bg-gray">
                <div class="layui-form-item">
                    <div style="margin-bottom: 10px">
                        <label class="layui-form-label" style="width: 60px">配件名称</label>
                        <div class="layui-inline">
                            <input type="text" class="layui-input d-filter" style="width: 200px">
                        </div>
                    </div>
                    <table lay-filter="table-left" lay-data="{id:'table-left'}" id="table-left"></table>
                </div>
            </div>
            <div class="right">
                <p>双击删除配件</p>
                <hr class="layui-bg-gray">
                <p>配件使用清单</p>
                <hr class="layui-bg-gray">
                <div class="layui-form-item" style="height: 32px;line-height: 32px;text-align: right">
                    *使用数量单击可编辑
                </div>
                <table lay-filter="table-right" lay-data="{id:'table-right'}" id="table-right"></table>

            </div>
        </div>
        <div class="layui-form-item" style="text-align: center;">
            <button class="layui-btn" lay-submit="" lay-filter="btn-list">保存</button>
        </div>
    </form>
</script>
<script type="text/html" id="price">
    <p>{{(d.price / 100).toFixed(2) }}</p>
</script>
<script type="text/html" id="remainingNumber">
    <p>{{d.totalNumber - d.useNumber}}</p>
</script>
<script type="text/html" id="headbar">
    <span class="layui-btn " id="{{d.aaa}}"  data-mastername="{{d.masterName}}"  lay-event="edit">
        <i class="layui-icon layui-icon-add-1"></i>
        编辑
    </span>
</script>

<script type="text/html" id="d-usenumber">
    {{# if(d.totalNumber - d.useNumber >= 0){ }}
        <p>{{d.useNumber}}</p>
    {{# }else{ }}
    <p>0</p>
    {{# } }}
    <!--<p>{{d.useNumber}}</p>-->
</script>

<script th:inline="javascript">
    var partsList = [[${partVO.partMasterVOList}]];
    //var conversionMap = [[${conversionMap}]];
    var partsVO = [[${partVO}]];
    console.log(partsVO);
    var layuiModel = {
        oms_work_modify_part: "work/modify/zmn.oms.work.modify.part"
    }
</script>
</body>
</html>